﻿package domino 
{
	import flash.display.DisplayObjectContainer;
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.geom.Matrix;
	/**
	 * ...
	 * @author sergiy
	 */
	
	public class BG2
	{
	     [Embed(source="img/cross.svg")]
           public var crossSVG:Class;
		   
		 [Embed(source="img/arrowsCircle.svg")]
           public var aCircle:Class;
		   
		 [Embed(source="img/arrowsCircle2.svg")]
           public var aCircle2:Class;    
		   
		 [Embed(source="img/star.svg")]
           public var starSVG:Class;
		   
		 [Embed(source="img/pendulum.svg")]
           public var pendulumSVG:Class; 
		   
		  [Embed(source="img/pendulum2.svg")]
           public var pendulumSVG2:Class;
		   
		   [Embed(source="img/tri2.svg")]
           public var triSVG:Class;
		  
		    [Embed(source="img/tri.svg")]
           public var triSVG2:Class;
		   
		    [Embed(source="img/trident.svg")]
           public var tridentSVG:Class;
		   
		   
		   [Embed(source="img/trident2.svg")]
           public var tridentSVG2:Class;
		   
		    [Embed(source="img/domino.svg")]
           public var domSVG:Class;
		   
		   [Embed(source="img/domino2.svg")]
           public var domSVG2:Class;
		   
		    [Embed(source="img/circle.svg")]
           public var circleSVG:Class;
		 
		 [Embed(source="img/circle2.svg")]
           public var circleSVG2:Class;
		   
		   private var classArray:Array =  new Array();  
		private var bitmapData:BitmapData;
		private var bmp:Bitmap;	
		private var movie:MovieClip= new MovieClip();
		private var frames:Array = [];
		public function BG2(parent:DisplayObjectContainer) 
		{
		    for (var i:int = 0; i < 20; i++ ) {      
			       classArray.push(new crossSVG());
				   classArray.push(new aCircle());
				   classArray.push(new aCircle2());
				   classArray.push(new starSVG());
				   classArray.push(new pendulumSVG());
				   classArray.push(new pendulumSVG2());
				   classArray.push(new triSVG());
				   classArray.push(new triSVG2());
				   classArray.push(new tridentSVG());
				   classArray.push(new tridentSVG2());
				   classArray.push(new domSVG());
				   classArray.push(new circleSVG());
				   classArray.push(new circleSVG2());
			}
				   
				    
					   
					   for each( var s:Sprite in classArray) {
						  
						    var scale:Number = Math.random() * 5;
						    s.alpha = Math.random()/12;
						    s.scaleX = scale;
						    s.scaleY = scale;
						    s.x = Math.random() * 640;
						    s.y = Math.random() * 480;
							//trace(s.y+ "y" + i + "type" +s);
						    s.rotation = Math.random() * 360;
						 
						    movie.addChild(s);
						//	var sss:Sprite = new Sprite();
							
	     				   }
					   
					   
					   
					   //movie.addChildAt
					   movie.cacheAsBitmap = true;
					   parent.addChildAt(movie,1);
			      /* bitmapData = new BitmapData(640, 480, false, 0x000000);
			        //bmp = new Bitmap(bmpData);
					var m:Matrix = new Matrix();
				    movie.width = 640;
					movie.height = 480;
					
					m.translate(640, 480);
				    m.scale(movie.scaleX, movie.scaleY);
				    bitmapData.draw(movie,m);
				    frames.push(bitmapData);
					trace(BitmapData+ " bitmap")
					trace(frames+ " frames");*/
		}
		
		public function remove(parent:DisplayObjectContainer):void {
			
			parent.removeChild(movie);
		//	spriteForAdding
		;
			}
	}

}